{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}

<div class="p-3">
	<form class="layui-form gg-form-bar border-t border-x">
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
		</div>
	</form>
	<table class="layui-hide" id="chapter_verify" lay-filter="chapter_verify"></table>
</div>

<script type="text/html" id="toolbarDemo">
	
</script>

<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">审核</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
</script>

{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function feiniaoInit() {
		var table = layui.table,tool = layui.tool, form = layui.form;
		layui.pageTable = table.render({
			elem: '#chapter_verify',
			title: '章节审核列表',
			toolbar: '#toolbarDemo',
			url: "{:url('chapter_verify/datalist')}",
			page: true,
			limit: 20,
			//cellMinWidth: 300,
			cols: [
				[
				{
					fixed: 'left',
					field: 'id',
					title: '编号',
					align: 'center',
					width: 80
				},{
					field: 'author',
					title: '作者',
					align: 'center',
					width: 150
				},{
					field: 'btitle',
					title: '作品',
					align: 'center',
					width: 250
				},{
					field: 'title',
					title: '章节标题',
				},{
					field: 'chaps',
					title: '章节序号',
					align: 'center',
					width: 100
				},{
					field: 'wordnum',
					title: '字数',
					align: 'center',
					width: 100
				},{
					field: 'create_time',
					title: '创建时间',
					align: 'center',
					width: 150,
				},{
					field: 'update_time',
					title: '更新时间',
					align: 'center',
					width: 150,
					templet:function(d) {
						return d.update_time ? layui.util.toDateString((parseInt(d.update_time) * 1000), 'yyyy-MM-dd HH:mm:ss') : '--';
					}
				},
				{
					fixed: 'right',
					field: 'right',
					title: '操作',
					toolbar: '#barDemo',
					width: 136,
					align: 'center'
				}				
				]
			]
		});
		
		//监听表头工具栏事件
		table.on('toolbar(chapter_verify)', function(obj){
		});

		//监听表格行工具事件
		table.on('tool(chapter_verify)', function(obj) {
			var data = obj.data;
			if (obj.event === 'read') {
				tool.side("{:url('chapter_verify/read')}?id="+obj.data.id);
			}
			else if (obj.event === 'del') {
				layer.confirm('确定要删除该记录吗?', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("{:url('chapter_verify/del')}", { id: data.id }, callback);
					layer.close(index);
				});
			}
			return false;
		});

		//监听搜索提交
		form.on('submit(searchform)', function(data) {
			layui.pageTable.reload({
				where: {
					keywords: data.field.keywords
				},
				page: {
					curr: 1
				}
			});
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->